﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Zor_DAL;
using Zor_Modes;
using Zor_Tools;

namespace Zor_Bll
{
    public class SearchPay_Bll<T> where T : class
    {
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="index">页码</param>
        /// <param name="TotalCount">返回值</param>
        /// <returns></returns>
        public static List<T> GetPageList(dynamic model, int index, out int TotalCount, string where)
        {
            var sqlSurch = string.Empty;
            if (model.Bd_Name != null)
            {
                sqlSurch += " Bd_Name like '%" + model.Bd_Name + "%' and ";
            }
            if (model.Uim_Name != null)
            {
                sqlSurch += " Uim_Name like '%" + model.Uim_Name + "%' and ";
            }
            if (model.Hs_Number != null)
            {
                sqlSurch += " Hs_Number like '%" + model.Hs_Number + "%' and ";
            }
            if (model.NatPer_Name != null)
            {
                sqlSurch += "NatPer_Name like '%" + model.NatPer_Name + "%' and ";
            }
            if (model.Hs_Proportion != 0)
            {
                sqlSurch += " Hs_Proportion like '%" + model.Hs_Proportion + "%' and ";
            }
            if (model.NatSex != null)
            {
                sqlSurch += "NatSex = '" + model.NatSex + "' and ";
            }
            if (model.NatPer_IDNumber != null)
            {
                sqlSurch += "NatPer_IDNumber = '" + model.NatPer_IDNumber + "' and ";
            }
            if (model.PtActualTax != 0)
            {
                sqlSurch += "PtActualTax = " + model.PtActualTax + " and ";
            }
            if (model.Nature != null)
            {
                sqlSurch += "Nature = '" + model.Nature + "' and ";
            }
            if (model.Acceptance_TaxStartTime != null)
            {
                int st = TimeHelper.ToTimeStamp(DateTime.Parse(model.Acceptance_TaxStartTime.ToString()));
                sqlSurch += "Acceptance_TaxStartTime = " + st + " and ";
            }
            if (model.Acceptance_TaxEndTime != null)
            {
                int et = TimeHelper.ToTimeStamp(DateTime.Parse(model.Acceptance_TaxEndTime.ToString()));
                sqlSurch += "Acceptance_TaxEndTime = " + et + " and ";
            }
            if (model.Pt_Date != null)
            {
                int pt = TimeHelper.ToTimeStamp(DateTime.Parse(model.Pt_Date.ToString()));
                sqlSurch += "Pt_Date = " + pt + " and ";
            }

            sqlSurch += " Dt_Id = "+ RequestSession.GetSessionUser().DT_Id +"";
            return PagerHelp<T>.GetPagerList(index, "V_SearchPay", "Pt_Id", out TotalCount, sqlSurch);
        }

        /// <summary>
        /// 获取租赁管理列表（不分页）
        /// create 刘云飞 by 2017/04/06       
        /// </summary>
        /// <returns></returns>
        public static List<T> GetList(dynamic model, string where)
        {
            var sqlSurch = string.Empty;
            if (model.Bd_Name != null)
            {
                sqlSurch += " Bd_Name like '%" + model.Bd_Name + "%' and ";
            }
            if (model.Uim_Name != null)
            {
                sqlSurch += " Uim_Name like '%" + model.Uim_Name + "%' and ";
            }
            if (model.Hs_Number != null)
            {
                sqlSurch += " Hs_Number like '%" + model.Hs_Number + "%' and ";
            }
            if (model.NatPer_Name != null)
            {
                sqlSurch += "NatPer_Name like '%" + model.NatPer_Name + "%' and ";
            }
            if (model.Hs_Proportion != 0)
            {
                sqlSurch += " Hs_Proportion like '%" + model.Hs_Proportion + "%' and ";
            }
            if (model.NatSex != null)
            {
                sqlSurch += "NatSex = '" + model.NatSex + "' and ";
            }
            if (model.Nature != null)
            {
                sqlSurch += "Nature = '" + model.Nature + "' and ";
            }
            if (model.Acceptance_TaxStartTime != null)
            {
                int st = TimeHelper.ToTimeStamp(DateTime.Parse(model.Acceptance_TaxStartTime.ToString()));
                sqlSurch += "Acceptance_TaxStartTime = " + st + " and ";
            }
            if (model.Acceptance_TaxEndTime != null)
            {
                int et = TimeHelper.ToTimeStamp(DateTime.Parse(model.Acceptance_TaxEndTime.ToString()));
                sqlSurch += "Acceptance_TaxEndTime = " + et + " and ";
            }
            sqlSurch += " Dt_Id = " + RequestSession.GetSessionUser().DT_Id + "";
            return SearchPay_DAL<T>.SelectViewSearchPay(sqlSurch);
        }

    }
}
